package cndw.core.dispatch;

import io.netty.channel.Channel;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 
 * @author zuojie.x
 */
public class ChannelSessionManager implements SessionManager {
	private ConcurrentHashMap<Channel, Session> channels = new ConcurrentHashMap<Channel, Session>(3096);
	
	@Override
	public Session getSession(Channel channel) {
		Session session = channels.get(channel);
		if (session == null) {
			session = new DefaultSession(channel);
			channels.putIfAbsent(channel, session);
		}
		return session;
	}

	@Override
	public Session removeSession(Channel channel) {
		return channels.remove(channel);
	}

}
